<?php
/* SVN FILE: $Id: cp_skin_splash.php 230 2009-09-26 23:05:21Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* ibMarket ACP home page html
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 230 $
* @lastrevision $Date: 2009-09-26 23:05:21 +0000 (Sat, 26 Sep 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-09-26 23:05:21 +0000 (Sat, 26 Sep 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/skin_cp/cp_skin_splash.php $
*/

class cp_skin_splash extends output
{

/**
 * Prevent our main destructor being called by this class
 *
 * @access	public
 * @return	void
 */
public function __destruct()
{
}

/**
 * 
 *
 * @access	public
 * @return	string	HTML
 */
public function splash_page( array $latestVersion, array $updates, array $statistics, array $people, array $latest ) {

$installed = $this->registry->getClass('class_localization')->formatTime($this->caches['app_cache']['ibmarket']['app_added'],'long');
$urls = array();
$urls['website']	= marketRegistry::website;
$urls['download']	= marketRegistry::download_ibMarket;
$urls['wiki']		= marketRegistry::wiki;
$urls['bugs']		= marketRegistry::reportBugs;
$urls['support']	= marketRegistry::supportTopic;

$this->lang->words['splash_most_money'] = sprintf($this->lang->words['splash_most_money'],$this->settings['market_currency']);
$this->lang->words['splash_money_circulating'] = sprintf($this->lang->words['splash_money_circulating'],$this->settings['market_currency']);
$statistics['total_items'] = sprintf($this->lang->words['total_items'],$this->registry->getClass('class_localization')->formatNumber($statistics['total_items']));
$statistics['unique_items'] = sprintf($this->lang->words['total_unique'],$this->registry->getClass('class_localization')->formatNumber($statistics['total_items']));
$statistics['plugins'] = sprintf($this->lang->words['total_plugins'],$this->registry->getClass('class_localization')->formatNumber($statistics['plugins']));
$statistics['wages'] = sprintf($this->lang->words['total_wages'],$this->registry->getClass('class_localization')->formatNumber($statistics['wages']));
$statistics['member_wages'] = sprintf($this->lang->words['total_member_wages'],$this->registry->getClass('class_localization')->formatNumber($statistics['member_wages']));
$statistics['group_wages'] = sprintf($this->lang->words['total_group_wages'],$this->registry->getClass('class_localization')->formatNumber($statistics['group_wages']));
$statistics['most_money'] = str_replace(array("<#MEMBER#>","<#MONEY#>"),array($statistics['most_money_member'],marketFormatter::formatCurrency($statistics['most_money'])),$this->lang->words['most_money']);
$statistics['money_circulating'] = sprintf($this->lang->words['money_circulating'],marketFormatter::formatCurrency($statistics['money_circulating']));
$statistics['most_inventory'] = str_replace(array("<#MEMBER#>","<#ITEMS#>"),array($statistics['most_inventory_member'],$this->registry->getClass('class_localization')->formatNumber($statistics['most_inventory'])),$this->lang->words['most_inventory']);
$statistics['total_inventory'] = sprintf($this->lang->words['total_inventory'],$this->registry->getClass('class_localization')->formatNumber($statistics['total_inventory']));
$statistics['most_bought'] = str_replace(array("<#ITEM#>","<#ITEMS#>"),array($statistics['most_bought_item'],$this->registry->getClass('class_localization')->formatNumber($statistics['most_bought'])),$this->lang->words['most_bought']);
$statistics['total_bought'] = sprintf($this->lang->words['total_bought'],$this->registry->getClass('class_localization')->formatNumber($statistics['total_bought']));

$_latest = 0;
$lastUpdated = $installed;
foreach($latestVersion as $version)
{
	if($_latest < $version['upgrade_version_id'])
	{
		$_latest = $version['upgrade_version_id'];
		$lastUpdated = $version['upgrade_date'];
	}
}
$lastUpdated = $this->registry->getClass('class_localization')->formatTime($lastUpdated,'long');

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['splash_welcome']}</h2>
</div>

EOF;
if($latest['available'][0] > $latest['latest'][0])
{
	$this->lang->words['newer_version_available_msg'] = sprintf($this->lang->words['newer_version_available_msg'],$latest['available'][2]);
	$IPBHTML .= <<<EOF
<div class='warning'>
	<h4><img src='{$this->settings['skin_acp_url']}/_newimages/icons/bullet_error.png' border='0' alt='{$this->lang->words['cp_error']}' /> {$this->lang->words['newer_version_available']}</h4>
	{$this->lang->words['newer_version_available_msg']}
</div>

EOF;
}
if($latest['latest'][0] > $latest['current'][0])
{
	$this->lang->words['unfinished_upgrade_msg'] = sprintf($this->lang->words['unfinished_upgrade_msg'],$this->settings['board_url'].'/'.CP_DIRECTORY.'/upgrade/index.php');
	$IPBHTML .= <<<EOF
<div class='warning'>
	<h4><img src='{$this->settings['skin_acp_url']}/_newimages/icons/bullet_error.png' border='0' alt='{$this->lang->words['cp_error']}' /> {$this->lang->words['unfinished_upgrade']}</h4>
	{$this->lang->words['unfinished_upgrade_msg']}
</div>

EOF;
}
if($this->settings['ipb_prune_task'])
{
	$setting = $this->DB->buildAndFetch(array('select'=>'*','from'=>'core_sys_conf_settings','where'=>"conf_key='ipb_prune_task'"));
	$this->lang->words['prune_log_enabled_msg'] = sprintf($this->lang->words['prune_log_enabled_msg'],$this->settings['base_acp_url'].'/index.php?adsess='.$this->request['adsess'].'&amp;app=core&amp;module=tools&amp;section=settings&amp;do=setting_view&amp;conf_group='.$setting['conf_group']);
	$IPBHTML .= <<<EOF
<div class='warning'>
	<h4><img src='{$this->settings['skin_acp_url']}/_newimages/icons/bullet_error.png' border='0' alt='{$this->lang->words['cp_error']}' /> {$this->lang->words['prune_log_enabled']}</h4>
	{$this->lang->words['prune_log_enabled_msg']}
</div>

EOF;
}
$IPBHTML .= <<<EOF

<div id='dashboard'>
	<div class='box-container'>
		<div id='overview' class='acp-box full-width'>
			<h3>{$this->lang->words['splash_overview']}</h3>
			<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
				<tr>
					<td>{$this->lang->words['splash_market_name']}</td>
					<td>{$this->settings['market_name']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_market_version']}</td>
					<td>{$this->caches['app_cache']['ibmarket']['app_version']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_installed']}</td>
					<td>{$installed}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_last_updated']}</td>
					<td>{$lastUpdated}</td>
				</tr>
			</table>
		</div>
	</div>
	
	<br />
	
	<div class='box-container'>
		<div id='overview' class='acp-box left-box'>
			<h3>{$this->lang->words['splash_latest_versions']}</h3>
			<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
				<tr>
					<th>{$this->lang->words['latest_id']}</th>
					<th>{$this->lang->words['latest_name']}</th>
					<th>{$this->lang->words['latest_time']}</th>
				</tr>
EOF;
foreach($latestVersion as $version)
{
	$version['upgrade_date'] = $this->registry->getClass('class_localization')->formatTime($version['upgrade_date'],'long');
	$IPBHTML .= <<<EOF
				<tr>
					<td>{$version['upgrade_version_id']}</td>
					<td style='white-space:nowrap'>{$version['upgrade_version_human']}</td>
					<td style='white-space:nowrap'>{$version['upgrade_date']}</td>
				</tr>
EOF;
}
$IPBHTML .= <<<EOF
			</table>
		</div>
		
		<div id='statistics' class='acp-box'>
			<h3>{$this->lang->words['splash_support']}</h3>
			<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
				<tr>
					<td>{$this->lang->words['splash_website']}</td>
					<td><a href='{$urls['website']}'>{$this->lang->words['website']}</a></td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_download']}</td>
					<td><a href='{$urls['download']}'>{$this->lang->words['download']}</a></td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_wiki']}</td>
					<td><a href='{$urls['wiki']}'>{$this->lang->words['wiki']}</a></td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_report_bug']}</td>
					<td><a href='{$urls['bugs']}'>{$this->lang->words['report_bug']}</a></td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_support_topic']}</td>
					<td><a href='{$urls['support']}'>{$this->lang->words['support_topic']}</a></td>
				</tr>
			</table>
		</div>
	</div>
	
	<br />
	
	<div class='box-container'>
		<div id='statistics' class='acp-box left-box'>
			<h3>{$this->lang->words['splash_market_updates']}</h3>
			<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
EOF;
foreach($updates as $update)
{
$IPBHTML .= <<<EOF
				<tr>
					<td>{$update}</td>
				</tr>

EOF;
}
$IPBHTML .= <<<EOF
			</table>
		</div>
		
		<div id='statistics' class='acp-box'>
			<h3>{$this->lang->words['splash_statistics']}</h3>
			<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
				<tr>
					<td>{$this->lang->words['splash_total_items']}</td>
					<td>{$statistics['total_items']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_total_unique']}</td>
					<td>{$statistics['unique_items']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_total_plugins']}</td>
					<td>{$statistics['plugins']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_total_wages']}</td>
					<td>{$statistics['wages']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_total_member_wages']}</td>
					<td>{$statistics['member_wages']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_total_group_wages']}</td>
					<td>{$statistics['group_wages']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_most_money']}</td>
					<td>{$statistics['most_money']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_money_circulating']}</td>
					<td>{$statistics['money_circulating']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_most_inventory']}</td>
					<td>{$statistics['most_inventory']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_total_inventory']}</td>
					<td>{$statistics['total_inventory']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_most_bought']}</td>
					<td>{$statistics['most_bought']}</td>
				</tr>
				<tr>
					<td>{$this->lang->words['splash_total_bought']}</td>
					<td>{$statistics['total_bought']}</td>
				</tr>
			</table>
		</div>
	</div>
	
	<br />
	
	<div class='acp-box'>
		<h3>{$this->lang->words['splash_people_in']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th>{$this->lang->words['people_name']}</th>
				<th>{$this->lang->words['people_when']}</th>
				<th>{$this->lang->words['people_where']}</th>
			</tr>
		</table>
	</div>
</div>
EOF;

return $IPBHTML;
}

/**
 * 
 *
 * @access	public
 * @return	string	HTML
 */
public function list_file_edits() {

$adminDir = CP_DIRECTORY;
$edits = array();
$edits['topics.php']['line'] = sprintf($this->lang->words['about_the_line_x'],2189);
$edits['threaded.php']['line'] = sprintf($this->lang->words['about_the_line_x'],260);

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['file_edits']}</h2>
</div>

<div id='fileEditsTopicsPHP'>
	<div class='acp-box'>
		<h3>
			{$adminDir}/applications/forums/modules_public/forums/topics.php ({$this->lang->words['optional']})
		</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th colspan='2'>{$edits['topics.php']['line']}</th>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['find']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="2">		/* Add custom fields join? */
		if( \$this->settings['custom_profile_topic'] == 1 )</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['under_the_function']}
				</td>
				<td>
					public function _getTopicDataLinear()
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['add_before']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="2">		\$_post_joins[0]['select'] .= ', m.'.\$this->settings['market_members_field'];
</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['it_will_look_like']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="4">		\$_post_joins[0]['select'] .= ', m.'.\$this->settings['market_members_field'];
		/* Add custom fields join? */
		if( \$this->settings['custom_profile_topic'] == 1 )</textarea>
				</td>
			</tr>
		</table>
	</div>
</div>
<br />
<div id='fileEditsThreadedPHP'>
	<div class='acp-box'>
		<h3>
			{$adminDir}/applications/forums/sources/classes/threaded.php ({$this->lang->words['optional']})
		</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th colspan='2'>{$edits['threaded.php']['line']}</th>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					Find
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="2">		/* Reputation system enabled? */
		if( \$this->settings['reputation_enabled'] )</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['under_the_function']}
				</td>
				<td>
					public function _getTopicDataThreaded()
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['add_before']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="2">		\$_post_joins[0]['select'] .= ', m.'.\$this->settings['market_members_field'];
</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['it_will_look_like']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="4">		\$_post_joins[0]['select'] .= ', m.'.\$this->settings['market_members_field'];
		/* Reputation system enabled? */
		if( \$this->settings['reputation_enabled'] )</textarea>
				</td>
			</tr>
		</table>
	</div>
</div>
<br />
<div id='skinEditsGlobal'>
	<div class='acp-box'>
		<h3>
			{$this->lang->words['skin_template']}: {$this->lang->words['bit_skin_global']} ({$this->lang->words['optional']})
		</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th colspan='2'>userInfoPane</th>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['find']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="1">		<if test="authorcfields:|:\$author['custom_fields'] != """></textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['add_before']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="10"><if test="marketMoney:|:isset(\$author[\$this->settings['market_members_field']]) && (\$this->memberData['member_id'] || \$this->settings['market_guests']) && (\$this->memberData['member_group_id'] == \$this->settings['admin_group'] || \$this->settings['market_show_money'])">
<php>
if(!class_exists('marketRegistry'))
{
	require_once( IPSLib::getAppDir('ibmarket')."/sources/marketRegistry.php");
	ipsRegistry::member()->setProperty('market_deduct', 1);
	marketRegistry::__setup();
}
</php>
			<li>
				<span class='ft'>{\$this->settings['market_currency']}:</span>
				<span class='fc'>{parse market_currency="\$author[\$this->settings['market_members_field']]"}</span>
			</li>

</if>
</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['it_will_look_like']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="10"><if test="marketMoney:|:isset(\$author[\$this->settings['market_members_field']]) && (\$this->memberData['member_id'] || \$this->settings['market_guests']) && (\$this->memberData['member_group_id'] == \$this->settings['admin_group'] || \$this->settings['market_show_money'])">
<php>
if(!class_exists('marketRegistry'))
{
	require_once( IPSLib::getAppDir('ibmarket')."/sources/marketRegistry.php");
	ipsRegistry::member()->setProperty('market_deduct', 1);
	marketRegistry::__setup();
}
</php>
			<li>
				<span class='ft'>{\$this->settings['market_currency']}:</span>
				<span class='fc'>{parse market_currency="\$author[\$this->settings['market_members_field']]"}</span>
			</li>

</if>
		<if test="authorcfields:|:\$author['custom_fields'] != """></textarea>
				</td>
			</tr>
		</table>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * 
 *
 * @access	public
 * @return	string	HTML
 */
public function itemTable($id, array $default) {

static $select = false;
if($select === false)
{
	$select = "";
	$IPBHTML .= <<<EOF
<script type='text/javascript' src='{$this->settings['js_app_url']}itemTable.js'></script>
<script type='text/javascript'>

EOF;
	foreach($this->caches['market_items'] as $item)
	{
		$select .= "<option value='".$item['item_id']."'>".$item['item_name']."</option>\n";
		$name = str_replace('"','\"',$item['item_name']);
		$IPBHTML .= <<<EOF
ibMarketTable.items[{$item['item_id']}] = "{$name}";

EOF;
	}
	$IPBHTML .= <<<EOF
</script>

EOF;
}
$_default = array();
if(count($default))
{
	foreach($default as $item_id => $quanity)
	{
		$_default[] = $item_id."=".$quanity;
	}
}
$value = implode(",",$_default);

$_id = str_replace("'","\\'",$id);
$IPBHTML .= <<<EOF
<input id='{$id}' type="hidden" value="{$value}" name='{$id}' />
<table width='100%' cellpadding='0' cellspacing='0' border='0' id='{$id}table'></table>
<select id='{$id}select' class='dropdown'>{$select}</select>
<input type='text' id='{$id}quanity' value="0" size='5' class='textinput' />
<input type='button' id='{$id}button' value="{$this->lang->words['add_item']}" class='textinput' />
<script type='text/javascript'>
ibMarketTable.register('{$_id}');
</script>

EOF;

return $IPBHTML;
}

}